package cn.edu.hitsz.compiler.parser.table.symbol;

import cn.edu.hitsz.compiler.lexer.Token;
import cn.edu.hitsz.compiler.parser.table.NonTerminal;
import cn.edu.hitsz.compiler.symtab.SourceCodeType;

import java.util.Objects;

/**
 * 语义分析type使用的数据结构
 */
public class SenSymbol extends Symbol {
    SourceCodeType sourceCodeType;//type

    public SenSymbol(Token token) {
        super(token);
        if(Objects.equals(token.getKindId(), "int"))  this.sourceCodeType = SourceCodeType.Int;
        else this.sourceCodeType = null;
    }

    public SenSymbol(NonTerminal nonTerminal){
        super(nonTerminal);
        this.sourceCodeType = null;
    }

    public SenSymbol(Token token,NonTerminal nonTerminal){
        super(token,nonTerminal);
        if(Objects.equals(token.getKindId(), "int"))  this.sourceCodeType = SourceCodeType.Int;
        else this.sourceCodeType = null;
    }


    public SourceCodeType getSourceCodeType(){return sourceCodeType;}
    public void setSourceCodeType(SourceCodeType sourceCodeType){this.sourceCodeType = sourceCodeType;}
}
